package com.controller;

import com.model.SysUser;
import com.page.GenericPage;
import com.po.DeviceReplenishRecordPO;
import com.po.ProductProcurementPO;
import com.po.ProductProcurementQueryPO;
import com.po.SysUserPO;
import com.result.Result;
import com.service.ProductProcurementService;
import com.vo.DeviceReplenishRecordVO;
import com.vo.ProductProcurementVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: chihaojie
 * @Date: 2019/7/31 15:50
 * @Version 1.0
 * @Note
 */

@Api(value = "procurementApi")
@CrossOrigin
@RestController
@RequestMapping("/procurement")
public class ProductProcurementController {


    @Autowired
    ProductProcurementService  productProcurementService;

    @ApiOperation(value = "新增", httpMethod = "POST", notes = "新增采购")
    @RequestMapping(value = "/save", method = RequestMethod.POST,produces = "application/json;charset=utf-8")
    public Result<Boolean> save(@RequestBody ProductProcurementPO procurementPO) {
        return new  Result<Boolean>().ok(productProcurementService.save(procurementPO));
    }

    @ApiOperation(value = "编辑", httpMethod = "POST", notes = "编辑")
    @RequestMapping(value = "/edit", method = RequestMethod.POST,produces = "application/json;charset=utf-8")
    public Result<Boolean> edit(@RequestBody ProductProcurementPO procurementPO) {
        return new  Result<Boolean>().ok(productProcurementService.edit(procurementPO));
    }

    @ApiOperation(value = "删除", httpMethod = "GET", notes = "删除")
    @RequestMapping(value = "/remove", method = RequestMethod.GET,produces = "application/json;charset=utf-8")
    public Result<Boolean> remove(@RequestParam("id") Long id) {
        return new  Result<Boolean>().ok(productProcurementService.remove(id));
    }


    @ApiOperation(value = "查询详情", httpMethod = "GET", notes = "查询详情")
    @RequestMapping(value = "/queryDetailInfo", method = RequestMethod.GET,produces = "application/json;charset=utf-8")
    public Result<ProductProcurementVO> queryDetailInfo(@RequestParam("id") Long id) {
        return new  Result<ProductProcurementVO>().ok(productProcurementService.queryDetailInfo(id));
    }

    @ApiOperation(value = "条件查询", httpMethod = "POST", notes = "条件查询")
    @RequestMapping(value = "/queryProductProcurementPage", method = RequestMethod.POST,produces = "application/json;charset=utf-8")
    public Result<GenericPage<ProductProcurementVO>> queryProductProcurementPage(@RequestParam(value = "pageNo",defaultValue = "1") Integer pageNo,
                                                                                 @RequestParam(value = "pageSize",defaultValue = "20") Integer pageSize,
                                                                                 @RequestBody ProductProcurementQueryPO queryPO) {
        return new Result<GenericPage<ProductProcurementVO>>().ok(productProcurementService.queryProductProcurementPage(pageNo,pageSize,queryPO)) ;
    }


}
